package com.cskaoyan.controller.admin;

import com.cskaoyan.bean.MarketIssue;
import com.cskaoyan.bean.MarketKeyword;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.bean.common.KeywordPageInfo;
import com.cskaoyan.service.KeywordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName:AdminKeywordController
 * @Description:TODO
 * @author:leiwenjie
 * @date:2022/9/8 17:50
 * @version:1.0
 */
@RestController
@RequestMapping("admin/keyword")
public class AdminKeywordController {

    @Autowired
    KeywordService keywordService;


    @RequestMapping("list")
    public BaseRespVo list(KeywordPageInfo info) {
        CommonData<MarketKeyword> data = keywordService.query(info);
        return BaseRespVo.ok(data);
    }

    // 需要解决回显
    @RequestMapping("create")
    public BaseRespVo create(@RequestBody MarketKeyword marketKeyword) {
        MarketKeyword keyword = keywordService.create(marketKeyword);
        return BaseRespVo.ok(keyword);
    }

    @RequestMapping("update")
    public BaseRespVo update(@RequestBody MarketKeyword marketKeyword) {
        keywordService.update(marketKeyword);
        return BaseRespVo.ok(null);
    }

    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody MarketKeyword marketKeyword) {
        keywordService.delete(marketKeyword);
        return BaseRespVo.ok(null);
    }
}
